<style scoped>
  .weui-form-preview__hd label, .weui-form-preview__hd em {
    font-size: .9em !important;
  }
  .rj-cell.max span{
    font-size: 16px;
    padding-right: 20px;
  }
  .rj-cell label {
    color: #333;
    font-size: 14px;
    width: 44%;
    display: inline-block;
    padding: 5px 3%;
    text-align: right;
  }
  .rj-cell span {
    font-size: 14px;
    color: #333;
    display: inline-block;
    width: 50%;
  }
  .rj-cell.note label{
    float: left;
  }
  .rj-cell.note span{
    width: 80%;
    display: inline-block;
  }
  .weui-cell {
    background: #fff;
  }
  .weui-cells__title {
    text-align: left;
  }
  .oitem {
    /*padding: 3px;*/
    margin: 5px;
  }
  .hide {
    display: none;
  }
  #acts {
    font-size: 0;
  }
  #acts span {
    font-size: 14px;
  }
  .weui-label {
    text-align: left;
  }
  .itembtn {
    position: absolute;
    right: 6px;
    top: 2px;
    z-index: 1;
    font-size: 12px;
    color: #04BE02;
    cursor: pointer;
  }
</style>
<template>
  <div class="oitem" style="position: relative;">
    <p v-show="total > 1" class="itembtn" @click="delCurrItem(product.guid)">删除</p>
    <!--    <input type="hidden" :name="'items[' + itemNo + '].linkid'" :value="product.guid" />-->
<!--    <input type="hidden" :name="'items[' + itemNo + '].itemguid'" :value="product.guid" />-->
<!--    <input type="hidden" :name="'items[' + itemNo + '].productguid'" :value="product.productid" />-->
<!--    <input type="hidden" :name="'items[' + itemNo + '].productname'" :value="product.product" />-->
<!--    <input type="hidden" :name="'items[' + itemNo + '].spguid'" :value="product.speid" />-->
<!--    <input type="hidden" :name="'items[' + itemNo + '].rawspguid'" :value="product.speid" />-->
<!--    <input type="hidden" :name="'items[' + itemNo + '].stockunit'" :value="product.stockunit" />-->
<!--    <input type="hidden" :name="'items[' + itemNo + '].stockunitid'" :value="product.stockunitid" />-->
<!--    <input type="hidden" :name="'items[' + itemNo + '].cospguid'" :value="product.cospguid" />-->
<!--    <div class="weui-cells__title">货品明细 {{itemNo + 1}}</div>-->
    <div class="weui-cell fir">
      <div class="weui-cell__hd"><label class="weui-label">产品</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text" name="" readonly="true" :value="product.product">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">规格</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input" type="text" name="" readonly="true" :value="product.spename">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label class="weui-label">数量{{product.stockunit ? `(${product.stockunit})` : ''}}</label></div>
      <div class="weui-cell__bd">
        <input class="weui-input weight" type="number" placeholder="请输入数量" v-model="weight"  @change="doEmitter">
      </div>
    </div>
    <div class="weui-cell">
      <div class="weui-cell__hd"><label for="" class="weui-label">库间</label></div>
      <div class="weui-cell__bd">
        <select class="weui-select houseroom" v-model="shrguid" >
          <option value="0">请选择库间</option>
          <option v-for="(hou, i) in houses" :value="hou.storeRhGuid">{{hou.storeRhName}} &nbsp; ({{hou.storeqty}} {{hou.stockunit}})</option>
        </select>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'OutStoreRmItem',
  data () {
    return {
      houses: [],
      shrguid: '',
      weight: ''
    }
  },
  props: [
    'itemNo',
    'product',
    'orgid',
    'strmid',
    'total',
  ],
  computed: {
  },
  watch: {
    'product': function (val) {
      this.getHouses();
    },
    'orgid': function (val) {
      this.getHouses();
    },
    'strmid': function (val) {
      this.getHouses();
    },
    'shrguid': function (val) {
      this.doEmitter();
    }
  },
  mounted() {
    this.getHouses();
  },
  methods: {
    delCurrItem(guid) {
      this.$emit('delItem', guid);
    },
    doEmitter(){
      this.model = {
        linkid: this.product.guid,
        itemguid: this.product.guid,
        productguid: this.product.productid,
        productname: this.product.product,
        // productname: this.currentProduct.productname,
        spguid: this.product.speid,
        rawspguid: this.product.speid,
        stockunit: this.product.stockunit,
        stockunitid: this.product.stockunitid,
        cospguid: this.product.cospguid,
        weight: this.weight,
        shrguid: this.shrguid,
      };
      this.model.index = this.itemNo;
      this.$emit('changeData', this.model);
    },
    getHouses: function() {
      // this.houses = [{"searchValue":null,"createBy":null,"createTime":null,"updateBy":null,"updateTime":null,"remark":null,"params":{},"guid":null,"storermguid":"542414C110644DD9B7D0E881968B55AE","batchid":null,"storehguid":null,"storehcode":null,"productid":"03949BC1F53E45E896B97B37117EE875","price":null,"wistartdate":null,"wienddate":null,"wostartdate":null,"woenddate":null,"createdate":null,"operatorid":null,"lastupdate":null,"orgguid":"162AE70D01A6427D916688DA1374D0EF","spguid":null,"shrtype":null,"stockunitid":null,"autoid":null,"type":null,"spectype":null,"srguids":null,"storename":"康莱纳（集宁工厂）","storeroomName":null,"orgname":"集宁工厂","productname":"荷兰十五","specName":null,"storeqty":63215.000000,"stockunit":"公斤","shrguid":null,"srguid":null,"starttime":null,"farmerid":null,"storeRhGuid":"36EC8E84EF164466A304996A08630450","storeRhName":"10#库"}]
      if (!this.checkNull(this.orgid) || !this.checkNull(this.strmid) || !this.checkNull(this.product.productid)) return;
      this.axios({
        method: 'get',
        url: '/prod-api/getPLInfo',
        params: {orgid: this.orgid, strmid: this.strmid, shrtype: this.product.picktype, productid: this.product.productid, spec: this.product.speid}
      }).then(response => {
        if (response.data.code == 200) {
          this.houses = response.data.data;
        } else if (response != undefined && response.data != undefined && response.data.msg == 'sessionTimeOut') {
          //不不设置提示
        } else {
          this.toastError('系统错误');
        }
      });
    },
    filterHouse: function(item) {
      return {title: item.storeroomName, value:item.storeroomguid, storeqty:item.storeqty, unit:item.unit, productid:item.productid};
    }
  }
}
</script>
